﻿using MediatR;
using Microsoft.EntityFrameworkCore;
using Traceability_Management.Domain;
using Traceability_Management.ErrorCode;
using Traceability_Management.Infrastructure.Interfaces;
using Traceability_Management.Read.Api.Application.Command.ThreeSelectWay;

namespace Traceability_Management.Read.Api.Application.CommandHandler.ThreeSelectWay
{
    public class ShowShengCommandHandler : IRequestHandler<ShowShengCommand, ApiResult<List<Slaughts_Sheng>>>
    {
        IBaseReponsitory<Slaughts_Sheng> Slaughts_Sheng;

        public ShowShengCommandHandler(IBaseReponsitory<Slaughts_Sheng> Slaughts_Sheng)
        {
            this.Slaughts_Sheng = Slaughts_Sheng;
        }

        public async Task<ApiResult<List<Slaughts_Sheng>>> Handle(ShowShengCommand request, CancellationToken cancellationToken)
        {
            var list =await Slaughts_Sheng.GetQuery().ToListAsync();
            return new ApiResult<List<Slaughts_Sheng>> 
            {
                Code=ApiEnum.False,
                Message="成功了",
                Data=list
            };
        }
    }
}
